package graph;

import java.util.TreeSet;



public class Node implements Comparable<Node> {
	//These will be the neighbors of the nodes
	private TreeSet<Node> ins;
	private TreeSet<Node> outs;
	
	private String out;
	private String in;
	
	private boolean startOfCycle;
	
	private boolean visited;
	private Node lastVisited;
	private int id;
	private int count;
	
	static int counter = 0;
	
	public Node(String _in, String _out, int _id)
	{
		ins = new TreeSet<Node>();
		outs = new TreeSet<Node>();
		
		lastVisited = null;
		out = _out;
		in = _in;
		
		counter++;
		count = counter;
		
		id = _id;
	}
	
	public void setStartOfCycle(boolean b)
	{
		startOfCycle = b;
	}
	
	public boolean getStartOfCycle()
	{
		return startOfCycle;
	}
	
	public void removeOutToNode(Node n)
	{
		if(ins.contains(n))
		{
			ins.remove(n);
		}
	}
	public void setLastVisited(Node n)
	{
		lastVisited = n;
	}
	
	public Node getLastVisited()
	{
		return lastVisited;
	}
	
	public boolean isVisited()
	{
		return visited;
	}
	public void setVisited(boolean b)
	{
		visited = b;
	}
	
	public TreeSet<Node> getInNeighbors()
	{
		return ins;
	}
	
	public TreeSet<Node> getOutNeighbors()
	{
		return outs;
	}
	 public void addInNeighbors(Node n)
	 {
		 ins.add(n);
	 }
	 
	 public void addOutNeighbors(Node n)
	 {
		 outs.add(n);
	 }
	 
	 public String getOutString()
	 {
		 return out;
	 }
	 
	 public String getInString()
	 {
		 return in;
	 }
	 
	 public int getCount()
	 {
		 return count;
	 }
	 
	 public int getID()
	 {
		 return id;
	 }
	 
	 public String toString()
	 {
		 return in + "|" + out + ":" + id;
	 }

	public int compareTo(Node o) {
		
		if(this.getCount() < o.getCount())
			return -1;
		else if(this.getCount() == o.getCount())
			return 0;
		else if(this.getCount() > o.getCount())
			return 1;
		
		return 12000;
		
		
	}
	 
	 
}
